<?php
/**
 * Default Template for Booking View
 */
defined('_JEXEC') or die('Restricted access');
$document =& JFactory::getDocument();
$document->addStyleSheet(JURI::base(). 'components/com_roombooking/assets/css/table.css');
$document->addScript(JURI::base() . 'components/com_roombooking/assets/js/jquery/jquery-1.5.2.min.js');
?>
<div class="componentheading"><?php echo JText::_( 'BOOKDETAILS' ); ?></div>
<table id="details-table">
 	<colgroup>
    	<col class="oce-first">
    </colgroup>

		<tr>
			<td width="100" align="right" class="key">
					<?php echo JText::_( 'SHORTDESC' ); ?>:
			</td>
			<td>
				<?php echo $this->item->short_description;?>
			</td>
		</tr>
		<tr>
			<td width="100" align="right" class="key">
					<?php echo JText::_( 'DESC' ); ?>:
			</td>
			<td>
				<?php echo $this->item->description;?>
			</td>
		</tr>
		<tr>
			<td width="20" align="right" class="key">
					<?php echo JText::_( 'START' ); ?>:
			</td>
			<td>
				<?php  echo $this->item->start;?>
			</td>
		</tr>
		<tr>
			<td width="20" align="right" class="key">
					<?php echo JText::_( 'END' ); ?>:
			</td>
			<td>
				<?php echo $this->item->end;?>
			</td>
		</tr>
		<tr>
			<td width="100" align="right" class="key">
					<?php echo JText::_( 'NOTES' ); ?>:
			</td>
			<td>
				<?php if(isset($this->item->notes)) echo $this->item->notes;?>
			</td>
		</tr>
		
		<tr>
			<td width="20" align="right" class="key">
					<?php echo JText::_( 'ROOM' ); ?>:
			</td>
			<td>
				<?php if(isset($this->roomName)) echo $this->roomName.' - '.$this->getBuildOfRoom($this->item->id_room); ?>
			</td>
		</tr>
		<tr>
			<td width="20" align="right" class="key">
					<?php echo JText::_( 'REPEAT' ); ?>:
			</td>
			<td>
				<?php 
				switch($this->item->repeat_type){
				case "0":{
					echo JText::_( 'NEVER' );
					break;
				}
				case "day":{
					echo JText::_( 'EVERYDAY' );
				 	break;		
				}
				case "week":{
					echo JText::_( 'EVERYWEEK' );
				 	break;
				}
				case "2week":{
					echo JText::_( 'EVERY2WEEK' );
				 	break;
				}
				case "month":{
					echo JText::_( 'EVERYMONTH' );
				 	break;
				}
				case "year":{
					echo JText::_( 'EVERYYEAR' );
				 	break;
				}
			}
				?>
			</td>
		</tr>
		<tr>
			<td width="20" align="right" class="key">
					<?php echo JText::_( 'UNTIL' ); ?>:
			</td>
			<td>
				<?php if(isset($this->item->repeat_until)){
					$until = new DateTime($this->item->repeat_until);
					echo $until->format('Y-m-d');
				} else echo "-"; ?>
			</td>
		</tr>
                <tr>
			<td width="20" align="right" class="key">
					<?php echo JText::_( 'Total Cost' ); ?>:
			</td>
			<td>
				<?php if(isset($this->item->total)){
					echo $this->item->total;
				} else echo "-"; ?>
			</td>
		</tr>
	</table>
	<table>
	<tr>
	<td>
            <form action="#" method="post" id="back" onsubmit="return confirm(b, a, c)">
		<input type="hidden" name="option" value="com_roombooking" />
		<input type="hidden" name="task" value="cancel" />
		<input type="hidden" name="controller" value="booking" />
		<input type="hidden" name="id_room" value="<?php echo $this->item->id_room; ?>" />
		<input type="submit" class="button" value="<?php echo JText::_( 'CALENDAR' );?>"/>
	</form>
	</td>
<td>
<?php 
$userID_logg = JFactory::getUser()->id;
$user_gid= JFactory::getUser()->gid;

$start = strtotime($this->item->start);
$now = strtotime(date('Y-m-d H:i:s'));

$hour = ($start - $now + 3600)/3600;

if(($this->item->id_user==$userID_logg || $user_gid>$this->edit_gid && $this->item->id!=0) && $hour >= 2){
//	echo '<td>
//			<form action="#" method="post" id="edit">
//				<input type="hidden" name="option" value="com_roombooking" />
//				<input type="hidden" name="task" value="edit" />
//				<input type="hidden" name="controller" value="booking" />
//				<input type="hidden" name="cid" value="'.$this->item->id.'" />
//				<input type="submit" class="button" value="'.JText::_( 'EDIT' ).'"/>
//			</form>
//		</td>
//		<td>
//			<form action="#" method="post" id="delete" >
//				<input type="hidden" name="option" value="com_roombooking" />
//				<input type="hidden" name="task" value="remove" />
//				<input type="hidden" name="controller" value="booking" />
//				<input type="hidden" name="id" value="'.$this->item->id.'" />
//				<input type="hidden" name="id_room" value="'.$this->item->id_room.'" />
//				<input type="submit" class="button" value="'.JText::_( 'DELETE' ).'"/>
//			</form>
//		</td>';
//	if (isset($this->item->series))
//	{
//		
//		echo'<td>
//		   <form action="#" method="post" id="deleteSeries">
//				<input type="hidden" name="option" value="com_roombooking" />
//				<input type="hidden" name="task" value="removeSeries" />
//				<input type="hidden" name="controller" value="booking" />
//				<input type="hidden" name="id" value="'.$this->item->id.'" />
//				<input type="hidden" name="id_room" value="'.$this->item->id_room.'" />
//				<input type="hidden" name="series" value="'.$this->item->series.'" />
//				<input type="submit" class="button" value="'.JText::_( 'DELETESERIES' ).'"/>
//			</form>
//		</td>';
//	}
}
?>
</td>
</table>
<script type="text/javascript">
    $('#delete,#deleteSeries').submit(function(){
        var con = confirm("本当ですか！");
        if(con == true)alert("罰金：5000￥");
        return con;
    });
</script>
